using Godot;
using System;

public partial class Sprite2d7 : Sprite2D
{
	[Export]
	public Texture2D newTexture;
	Double timer = 0;
	public override void _Ready()
	{
		// 加载纹理
		// this.Texture = GD.Load<Texture2D>("res://icon.svg");
		this.Texture = newTexture;
		// 中心点还是在左上角
		this.Centered = true;
		// 偏移
		this.Offset = new Vector2(100, 100);
		// 翻转
		// this.FlipH = true; // 水平翻转
		// this.FlipV = true; // 垂直翻转
		this.Hframes = 2; // 横向帧数
		this.Vframes = 2; // 纵向帧数
		this.Frame = 0; // 当前帧
	}

	// Called every frame. 'delta' is the elapsed time since the previous frame.
	public override void _Process(double delta)
	{
		timer += delta;
		if (timer > 1)
		{
			timer = 0;
			// 计算总帧数
			var all = this.Hframes * this.Vframes;
			// 切换帧
			this.Frame = (this.Frame + 1) % all;
		}
	}
}
